﻿@using System.Web.Mvc
@using System.Web.Mvc.Ajax
@using System.Web.Mvc.Html
@using nanoCMS.Forum.Resources
@using nanoCMS.Forum.WebUI.Models.ViewModels
@model EditThreadVM
<div id="edit_form">
    @using (Ajax.BeginForm("SaveThread", "Forum", new { area = "Forum" }, 
        new AjaxOptions { UpdateTargetId = "validationSummary", OnComplete = "SaveThreadComplete" }, new { }))
    {
        <div id="validationSummary" class="validationSummary">
        </div>
        <input type="hidden" name="ForumID" id="EditThreadVM_ForumID" value="@(Model.ForumID)"/>
        <input type="hidden" name="Thread.ThreadID" id="EditThreadVM_Thread_ThreadID" 
            value="@(Model.Thread.ThreadID)"/>
        <input type="hidden" name="link" value="@ViewContext.RequestContext.RouteData.Values["link"]"/>
        <input type="hidden" name="elementKey" value="@ViewBag.ElementKey"/>
        <fieldset id="">
            <legend>@Translation.CreateThread</legend>
            <div>
                <label for="EditThreadVM_Thread_Title">
                    @Translation.Title:</label>
                <input type="text" name="Thread.Title" id="EditThreadVM_Thread_Title" 
                    value="@Model.Thread.Title"/>
            </div>
            <div>
                <label for="EditThreadVM_Thread_Description">
                    @Translation.Description:</label>
                <input type="text" name="Thread.Description" id="EditThreadVM_Thread_Description" 
                    value="@Model.Thread.Description"/>
                <div>
                    <label for="EditThreadVM_Post_Content">
                        @Translation.PostContent</label>
                    <textarea rows="10" cols="50" name="Post.Content" id="EditThreadVM_Post_Content">@Model.Post.Content</textarea>
                </div>
            </div>
            <div>
                <input type="submit" value="@Translation.Save" />
            </div>
        </fieldset>
    }
</div>
<script type="text/javascript">
    function SaveThreadComplete(params) {
        ajaxFormSuccess(jQuery.parseJSON(params.responseText)); 
    }
</script>
